package org.snail.proxy.client;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class BytesEncoder extends MessageToByteEncoder<byte[]> {
    @Override
    protected void encode(ChannelHandlerContext ctx, byte[] bytes, ByteBuf out) {
        int length = bytes.length;// 读取 ProtoMsg 消息的长度
        ByteBuf buf = Unpooled.buffer(length);
        buf.writeBytes(bytes);
        out.writeBytes(buf);
    }
}
